package xiaomi;

import java.util.Scanner;

/**
 * @author Hang
 * @date 2022/9/20
 * @project AutumnOffer
 * @description
 **/
public class Solution2 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String x1 = sc.nextLine();
        String y1 = sc.nextLine();
        int m = x1.length(),n = y1.length();
        int[][] dp = new int[m+1][n+1];
        for(int i=0;i<=m;i++){
            dp[i][0] = i;
        }
        for(int j=0;j<=n;j++){
            dp[0][j] = j;
        }
        for(int i=1;i<=m;i++){
            for(int j=1;j<=n;j++){
                if(x1.charAt(i-1) == y1.charAt(j-1)){
                    dp[i][j] = dp[i-1][j-1];
                }else{
                    dp[i][j] = Math.min(Math.min(dp[i-1][j-1],dp[i-1][j]),dp[i][j-1])+1;
                }
            }
        }
        System.out.println(dp[m][n]);
    }
}
